package com.qisu.converters;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
 *
 * @author alsan
 *
 */
public final class SmallEndianFloatConverter implements FieldConverter<Float> {

	@Override
	public Float converter(byte[] data, int pos, int len) {
		if(null != data && data.length >= pos + len) {
			return ByteBuffer.wrap(data, pos, len).order(ByteOrder.LITTLE_ENDIAN).getFloat();
		}
		return 0f;
	}

	@Override
	public Float converter(byte[] data) {
		return converter(data, 0, 4);
	}

}
